class Solution(object):
    def getStrongest(self, arr, k):
        arr.sort()
        n = len(arr)
        m = arr[(n - 1) // 2]
        left = 0
        right = n - 1
        ans = []
        for i in range(k):
            if abs(arr[right] - m) >= abs(arr[left] - m):
                ans.append(arr[right])
                right -= 1
            else:
                ans.append(arr[left])
                left += 1
        return ans